package com.ronin.managed.bean;

import com.ronin.commmon.beans.util.JsfUtil;
import com.ronin.model.Arac;
import com.ronin.service.AracService;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.apache.log4j.Logger;

@ManagedBean(name = "aracMB")
@ViewScoped
public class AracMB implements Serializable {

    public static Logger logger = Logger.getLogger(AracMB.class);

    @ManagedProperty("#{aracService}")
    private AracService aracService;

    private Arac seleceted;
    private List<Arac> list;

    @PostConstruct
    public void init() {

    }

    public void add(Arac arac) {
        try {
            aracService.add(arac);
        } catch (Exception e) {
            logger.error(e.getStackTrace());
            JsfUtil.addSuccessMessage("Hata!");
        }
        JsfUtil.addSuccessMessage("?slem basarili");

    }

    public void update(Arac arac) {
        try {
            aracService.update(arac);
        } catch (Exception e) {
            logger.error(e.getStackTrace());
            JsfUtil.addSuccessMessage("Hata!");
        }
        JsfUtil.addSuccessMessage("?slem basarili");
    }

    public void delete(Arac arac) {
        try {
            aracService.update(arac);
        } catch (Exception e) {
            logger.error(e.getStackTrace());
            JsfUtil.addSuccessMessage("Hata!");
        }
        JsfUtil.addSuccessMessage("?slem basarili");
    }

}
